package com.iye.puretennis.helper;

import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: jing wu
 * Date: 2014/12/8
 * Time: 14:15
 */
public class Session {

    @SuppressWarnings("unchecked")
    private Map objectContainer;

    private static Session session;

    //Attention here, DO NOT USE keyword 'new' to create this object.
    //Instead, use getSession method.
    @SuppressWarnings("unchecked")
    private Session() {
        objectContainer = new HashMap();
    }

    public static Session newSession() {

        if (session == null) {
            session = new Session();

        }

        return session;

    }

    @SuppressWarnings("unchecked")
    public void put(Object key, Object value) {

        objectContainer.put(key, value);
    }

    public Object get(Object key) {

        return objectContainer.get(key);
    }

    public void cleanUpSession() {
        objectContainer.clear();
    }

    public void remove(Object key) {
        objectContainer.remove(key);
    }
}
